<template>
    <div class="my-business">
       <router-link tag="div" class="agent-item"  v-for="item in agentList" :key="item.id" :to="'/agent_item/' + item.id" >
            <!-- <img :src="item.url" class="business-img"> -->
            <span class="item-name">{{item.name}}</span>
            <span class="item-grade">{{item.grade}}</span>
            <span class="next-icon"></span>
       </router-link>
    </div>
</template>
<script>
import comDialog from '@/components/comDialog'
import { post } from '../../../../util/http.js'
import { Toast } from 'mint-ui'
export default {
    data () {
        return {
            grade: '',
            agentList: [
            // {
            //     id: 0,
            //     name: '伯乐优选',
            //     grade: '钻石代理商',
            //     url: require('@/assets/img/me/business_head.png')
            // }, {
            //     id: 1,
            //     name: '搜知云（北京）教育科技有限公司',
            //     grade: '一级代理商',
            //     url: require('@/assets/img/me/business_head.png')
            // }
            ]
        }
    },
    components: {
       comDialog 
    },
    mounted () {
        let info = JSON.parse(window.localStorage.getItem('dongHang_data'))
        post('http://dlsapi.rz158.com/agent/myAgent', {
            agentId: info.agentId
        }).then(res => {
            if(res.code == 0) {
                console.log(res)
                res.t.forEach(item => {
                    console.log('item.level', item.level)
                    switch (item.level) {
                        case 0:
                            this.grade = '钻石代理商'
                            break;
                         case 1:
                            this.grade = '金牌代理商'
                            break;
                        case 2:
                            this.grade = '超级节点'
                            break;
                        case 3:
                            this.grade = '普通节点'
                            break;
                        default:
                            break;
                    }
                    let obj = {
                        id: item.id,
                        name: item.company,
                        grade: this.grade
                    }
                    this.agentList.push(obj)
                })
            } else {
                Toast({
                    message: res.message,
                    duration: 1000
                })
            }
        })
    },
    methods: {
    }
}
</script>

<style lang="less" scoped>
.my-business{
    padding-left: .3rem;
    .agent-item{
        position: relative;
        padding: .3rem 0rem;
        height: 1rem;
        border-bottom: 1px solid #cccccc;
        width: 100%;
        .item-name{
            position: absolute;
            display: inline-block;
            font-size:.32rem;
            font-weight: bold;
            margin-top: .3rem;
            margin-left: .34rem;
            max-width: 5.4rem;
        }
        .item-grade{
            position: absolute;
            display: inline-block;
            margin-top: .6rem;
            margin-left: .34rem;
            font-size:.28rem;
        }
        .next-icon {
            float: right;
            width: 0.12rem;
            height: 0.2rem;
            background: url('../../../assets/img/next-icon.png') no-repeat;
            background-size: 100%;
            margin-top: 0.42rem;
            margin-right: .3rem;
        }
    }
}
  .business-img{
     width: 1rem;
  }
 .business-cell{
    padding: .2rem .2rem .2rem 0rem;
    border-bottom: 1px solid #ccc;
 }
</style>
